package com.scau.databaseexam.DAO;



import com.scau.databaseexam.beans.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserDao {

    @Select("select * from user")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "password",property = "password")
    })
    public List<User> selectUsers();

    @Select("select * from user where id=#{id}")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "password",property = "password")
    })
    public  User selectUser(String id);

    @Update("UPDATE user set name=#{name} where id=#{id};")
    public void updateUser(User user);

    @Insert("insert into user(id, name, password) values(#{id},#{name},#{password});")
    public void insertUser(User user);

    @Delete("DELETE FROM user where id=#{id}")
    public void deleteUser(int id);
}
